﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace huaguwang
{
      //======================================================================
      //
      //        Copyright (C) 苏州逸仙软件    
      //        All rights reserved
      //
      //        filename :D_T_SoftWareComment_Exp
      //        description :炒股软件专家评论相关
      //
      //        created by 何庆 at  2010年12月20日
      //
      //======================================================================
      public class D_T_SoftWareEvaluating_Exp : D_T_SoftWareEvaluating
      {
            /// <summary>
            /// 专家评测扩展表
            /// </summary>
            public class SoftWareCommentExp : M_T_SoftWareEvaluating
            {
                  public string SoftWareName { get; set; }
            }

            /// <summary>
            /// 根据条件查询软件评论列表
            /// </summary>
            /// <param name="begin">跳过的记录数</param>
            /// <param name="pageSize">每页记录数</param>
            /// <param name="softName">软件名称</param>
            /// <param name="softCommentTitle">评论标题</param>
            /// <param name="queryCount">引用参数返回查询记录数</param>
            /// <returns>满足条件软件评论列表</returns>
            public List<SoftWareCommentExp> GetSoftWareCommentList(int begin, int pageSize, string softName, string softCommentTitle, ref int queryCount)
            {
                  string strTable = "dbo.T_SoftWare as a inner join dbo.T_SoftWareEvaluating as b on a.id = b.SoftWareID inner join T_AdminUser as c on b.UserID = c.id ";
                  string strWhere = "a.Flag = 1 and b.Title like '%'+@SoftCommentTitle+'%' and a.Title like '%'+@SoftName+'%'  and b.Flag = 1";
                  string strQuerycountSQL = ExpandMSSQL.GetPageSQL(strTable, strWhere);
                  SqlParameter[] sqlParam = new SqlParameter[]
                  {
                        new SqlParameter("@SoftName",SqlDbType.NVarChar,50){ Value=softName},
                        new SqlParameter("@SoftCommentTitle", SqlDbType.NVarChar,1000){ Value=softCommentTitle}
                  };
                  queryCount = MSSQLHelper.SQLConType.C1.Exp_GetSingle(strQuerycountSQL, sqlParam).Exp_IntTryParse();

                  string strSQL = ExpandMSSQL.GetPageSQL(begin, pageSize, "b.*,a.Title as softtitle,c.RealName ", strTable, "b.id", strWhere, "b.UploadDate desc,b.Topis desc,a.title");
                  var vResult = MSSQLHelper.SQLConType.C1.Exp_GetList<SoftWareCommentExp>(strSQL, row => new SoftWareCommentExp
                  {
                        id = row["id"].Exp_IntTryParse(),
                        Title = row["Title"].Exp_Trim(),
                        Contents = row["Contents"].Exp_Trim(),
                        Pic = row["RealName"].Exp_Trim(),//该变量用来存储操作人真是姓名
                        Source = row["Source"].Exp_Trim(),
                        ColorKey = row["ColorKey"].Exp_Trim(),
                        ColorTitle = row["ColorTitle"].Exp_Trim(),
                        ExteriorKey = row["ExteriorKey"].Exp_Trim(),
                        Flag = true,
                        InteriorKey = row["InteriorKey"].Exp_Trim(),
                        SoftWareID = row["SoftWareID"].Exp_IntTryParse(),
                        SoftWareName = row["SoftTitle"].Exp_Trim(),
                        Topis = row["Topis"].Exp_IntTryParse(),
                        UploadDate = row["UploadDate"].Exp_DateTimeTryParse(),
                        RemSign = row["RemSign"].Exp_BoolTryParse(),
                        WebTitle = row["WebTitle"].Exp_Trim(),
                        WebKey = row["WebKey"].Exp_Trim(),
                        WebSummary = row["WebSummary"].Exp_Trim()
                  }, sqlParam);
                  return vResult;
            }
      }
}
